package entjava.poker.model;

import entjava.poker.service.ComboService;

public class Hand {  

	private Card[] cardList= new Card[7];
	private int count=0;
	private int cardNum=-1;
	private ComboService combo;
	private Card highcard;
	private int rankScore=0;
	private boolean hasCombo;
	private String com;
	private String[] path = new String[7];
	
	public Hand(){
	
		this.combo=new ComboService(cardList);
		this.hasCombo=false;
		System.out.println("hand was created");
		
	}
	
	public void add(Card dcard){
		
		if(count< getCardList().length ){
			getCardList()[count]=dcard;
			getPath()[count]=dcard.getPath();
	//		System.out.println("path of card: "+dcard.getPath());
			setCardNum(getCardNum() + 1);			
			System.out.println("card number: "+getCardNum());
	
		}
		count++;
	}
	
	public void removeCards(){
		
		//remove stuff
	
	}
	
	
	
	public void knowBestHand(){
					//check if there's a combo made
		System.out.println("knowBestHand   no in print");
		if(this.combo.RoyalFlush() || this.combo.StraightFlush() || this.combo.FourOfAKind() || this.combo.FullHouse() || this.combo.Flush() || this.combo.Straight() || this.combo.ThreeOfAKind() || this.combo.TwoPair() || this.combo.OnePair()){
				System.out.println("inside knowBestHand  combo");
			
				if(this.combo.RoyalFlush()){
					System.out.println("you have Royal flush");
					this.setCom(" have Royal flush");
				this.rankScore=100;
				rankScore+=this.combo.higherCard().getRankNum();
			}else if(this.combo.StraightFlush()){	
				System.out.println("straight");
				this.setCom(" have sTRAIGHT Flush");
				this.rankScore=90;
				rankScore+=this.combo.higherCard().getRankNum();
			}else if(this.combo.FourOfAKind()){			//rank value example 10 > 3 matters in winning
				this.rankScore=80;
				this.setCom(" have FourOfAKind");
				rankScore+=this.combo.higherCard().getRankNum();
			//		this.combo.getHighrankFourOfAKind();
			}else if(this.combo.FullHouse()){			//know the rank card of three of a kind
				this.rankScore=70;
				this.setCom(" have FullHouse");
			//		this.combo.getHighrankThreeOfAKind();	
				rankScore+=this.combo.higherCard().getRankNum();
			}else if(this.combo.Flush()){				
				this.rankScore=60;
				this.setCom(" have Flush");
				rankScore+=this.combo.higherCard().getRankNum();
			}else if(this.combo.Straight()){			//know the lowest card to compare with others and know its value in chase of a tie
				this.rankScore=50;
				this.setCom(" have Straight");
				rankScore+=this.combo.higherCard().getRankNum();
			}else if(this.combo.ThreeOfAKind()){		//rank value example 10 > 3 matters in winning
				this.rankScore=40;
				this.setCom(" have three of a kind");
				rankScore+=this.combo.higherCard().getRankNum();

			//		this.combo.getHighrankThreeOfAKind();	
			}else if(this.combo.TwoPair()){				//rank value example 10 > 3 matters in winning
				this.rankScore=30;
				this.setCom(" have two pair");
				rankScore+=this.combo.higherCard().getRankNum();
			//		this.combo.getHighrankTwoPair();	
			}else if(this.combo.OnePair()){				//rank value example 10 > 3 matters in winning
				this.rankScore=20;
			//		this.combo.getHighrankOnePair();
				this.setCom(" have one pair");
				rankScore+=this.combo.higherCard().getRankNum();

			}
			
			this.setHasCombo(true);
			
		}else{		//Check Player's High Card
			System.out.println("inside knowBestHand no Combo");
			this.highcard =this.combo.higherCard();
			this.rankScore = highcard.getRankNum();
			this.setCom(" have a high Card");
		}
	}
	


	public void setCardList(Card[] cardList) {
		this.cardList = cardList;
	}

	public Card[] getCardList() {
		return cardList;
	}

	public void setCardNum(int cardNum) {
		this.cardNum = cardNum;
	}

	public int getCardNum() {
		return cardNum;
	}

	public ComboService getCombo() {
		return combo;
	}

	public void setCombo(ComboService combo) {
		this.combo = combo;
	}

	public Card getHighcard() {
		return highcard;
	}

	public void setHighcard(Card highcard) {
		this.highcard = highcard;
	}

	public int getRankScore() {
		return rankScore;
	}

	public void setRankScore(int rankScore) {
		this.rankScore = rankScore;
	}

	public boolean isHasCombo() {
		return hasCombo;
	}

	public void setHasCombo(boolean hasCombo) {
		this.hasCombo = hasCombo;
	}

	public String getCom() {
		return com;
	}

	public void setCom(String com) {
		this.com = com;
	}

	public String[] getPath() {
		return path;
	}

	public void setPath(String[] path) {
		this.path = path;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int c) {
		this.count = c;
	}
	
}
